package com.shop.dingdongshoppingapi.controller;

import com.shop.dingdongshoppingapi.dto.OrderAddDto;
import com.shop.dingdongshoppingapi.service.intf.OrderService;
import com.shop.dingdongshoppingapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/order/")
@Api(tags = "订单接口")
@CrossOrigin
public class OrderController {
    @Resource
    private OrderService service;

    @ApiOperation("添加订单")
    @PostMapping("add.do")
    public R add(@RequestBody OrderAddDto dto, HttpServletRequest request){
        return service.add(request.getIntHeader("ddstoken"),dto);
    }
    //查询订单
    @GetMapping("selectInfo.do")
    @ApiOperation("查询订单信息")
    public R selectInfo(HttpServletRequest request) {
        return service.selectInfo(request.getIntHeader("ddstoken"));
    }
}
